home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14161 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: nntp.teleport.com!usenet
  2. From: GHouck <hksys@teleport.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help:what is wrong this code?
  5. Date: 12 Apr 1996 03:50:09 GMT
  6. Organization: systems hk
  7. Message-ID: <4kkjth$c32@nadine.teleport.com>
  8. References: <4k3p3q$n76@brahms.udel.edu> <4k4hi3$5hm@sparcserver.lrz-muenchen.de> <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>
  9. NNTP-Posting-Host: ip-pdx08-22.teleport.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  14.  
  15. Norma Mathews <n9341884@henson.cc.wwu.edu> wrote:
  16. >On 6 Apr 1996, Kurt Watzka wrote:
  17. >> yuehong@brahms.udel.edu (Yue-hong Zheng) writes:
  18. >> >Why it give me 0.0000?
  19. >>
  20. >> >#include <stdio.h>
  21. >> >main () {
  22. >> >double a=9.008;
  23. >> >printf("%f\n",sqrt(a));
  24. >> >return 0;
  25. >> >}
  26. >
  27. >your printf specifer needs to be "%lf", not "%f", since a is a double
  28. >
  29. Probably more likely because the 'math.h' include file
  30. is not present, so 'sqrt()' is possibly returning an
  31. integer by default.
  32. Yours, Geoff Houck
  33.  
  34.